import numpy as np
import matplotlib.pyplot as plt

# 创建 x 值的数组
x = np.linspace(0, 2*np.pi, 1000)

# 计算 sin(x) 和 cos(x)
sin_x = np.sin(x)
cos_x = np.cos(x)

# 计算 sin(x)^2 + cos(x)^2
result = np.sqrt(np.power(sin_x, 2) + np.power(cos_x, 2))

# 绘制结果
plt.figure(figsize=(10, 6))
plt.plot(x, result, label='sin(x)^2 + cos(x)^2')
plt.axhline(y=1, color='r', linestyle='--', label='y = 1')
plt.xlabel('x')
plt.ylabel('Value')
plt.title('Demonstration of sin(x)^2 + cos(x)^2 = 1')
plt.legend()
plt.grid(True)
plt.show()
